Skip to content

fix(filebrowser): require agent_name when subdomain is false#877

Merged
DevelopmentCats merged 2 commits intomainfrom
fix/filebrowser-agent-name-validation
May 4, 2026
Merged

fix(filebrowser): require agent_name when subdomain is false#877
DevelopmentCats merged 2 commits intomainfrom
fix/filebrowser-agent-name-validation

Conversation

@blinkagent
Copy link
Copy Markdown
Contributor

@blinkagent blinkagent Bot commented Apr 29, 2026

Description

Fixes REG-4: the filebrowser module opens to a non-existent URL with the workspace path appended a second time when subdomain = false and agent_name is not provided, e.g.:

https://<coder-host>/@<owner>/<workspace>/apps/filebrowser/files/@<owner>/<workspace>.<agent>/apps/filebrowser/

Root cause

Coder's frontend always builds path-based app URLs as /@<owner>/<workspace>.<agent>/apps/<slug>/ (it always includes .<agent_name>, even for single-agent templates):

https://github.com/coder/coder/blob/main/site/src/modules/apps/apps.ts

return `${path}/@${workspace.owner_name}/${workspace.name}.${agent.name}/apps/${app.slug}/`;

The filebrowser module, however, only includes the agent segment in local.server_base_path (which becomes filebrowser's --baseURL) when the user explicitly passes agent_name. The variable description and the README both said agent_name was "only required if the template uses multiple agents", which is incorrect.

When the URLs disagree, filebrowser's reverse-proxy stripPrefix cannot strip the prefix, the path falls through filebrowser's /:catchAll(.*)* Vue route, and the router redirects to /files/${catchAll} — producing the duplicated path the user reported.

Fix

  • Add a lifecycle.precondition on coder_script.filebrowser that fails terraform apply with a clear, actionable error when subdomain = false and agent_name == null.
  • Update the agent_name variable description to state it is required whenever subdomain is false.
  • Update the README.md example for the path-based config to call out the requirement explicitly.
  • Bump the module version from 1.1.41.1.5.
  • Add a TS test covering the new precondition.

This avoids the silent misconfiguration that produces the duplicated URL, without breaking anyone whose existing template already sets agent_name (or uses subdomain = true).

Type of Change

  • New module
  • New template
  • Bug fix
  • Feature/enhancement
  • Documentation
  • Other

Module Information

Path: registry/coder/modules/filebrowser
New version: v1.1.5
Breaking change: [ ] Yes [x] No

Testing & Validation

  • bun test main.test.ts — 8 pass, 0 fail (includes new precondition test)
  • terraform fmt -recursive
  • terraform validate
  • bun x prettier --check
  • Manually verified the precondition fires with a minimal repro and passes when agent_name is supplied or subdomain = true.

Related Issues


Created on behalf of @matifali.

Generated with Blink.

Coder always builds path-based app URLs as /@<owner>/<workspace>.<agent>/apps/<slug>/, so the filebrowser baseURL must include the agent name to match the URL the user is actually browsing. When agent_name is omitted with subdomain=false, the baseURL is /@<owner>/<workspace>/apps/<slug> (no agent name), and filebrowser fails to strip the prefix from incoming requests. Its catch-all router then redirects to /files/<original-path>, producing duplicated paths like /@<owner>/<workspace>/apps/filebrowser/files/@<owner>/<workspace>.<agent>/apps/filebrowser/.

Add a lifecycle precondition that fails terraform apply with a clear error when subdomain=false and agent_name is not provided. Update the variable description and README accordingly, and bump the module to 1.1.5.
Copy link
Copy Markdown
Member

matifali commented May 4, 2026

@DevelopmentCats can you give it a review. Thanks

@DevelopmentCats DevelopmentCats added the version:minor Add to PRs requiring a minor version upgrade label May 4, 2026
Copy link
Copy Markdown
Collaborator

@DevelopmentCats DevelopmentCats left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM this seems like a straightforward fix to me.

@coder coder deleted a comment from github-actions Bot May 4, 2026
@DevelopmentCats DevelopmentCats added version:patch Add to PRs requiring a patch version upgrade and removed version:minor Add to PRs requiring a minor version upgrade labels May 4, 2026
@DevelopmentCats DevelopmentCats merged commit 4688e4c into main May 4, 2026
4 checks passed
@DevelopmentCats DevelopmentCats deleted the fix/filebrowser-agent-name-validation branch May 4, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

version:patch Add to PRs requiring a patch version upgrade

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants